#include<iostream>

#define Size 10 
#define INF = 1000
int visited[Size] = { 0 };
template<class T>
class Graph
{
public:
  Graph(){};
  Graph(T a[],int n, int e);
  ~Graph(){};
    Queue Queue(int Size)
    void minpath(T P[Size][Size], T D[Size][Size]);
private:
    T vertex[Size];
    T edge[Size][Size];
    int adjvex;
    int vertexnode;
    Graph* next;
    Graph* firstedge;
    int vertexnum, edgenum;
};

Graph<T>::Queue Queue(int Size){
	Queue Q = (Queue)malloc(sizeof(struct QNode));
	Q->Data = (ElementType *) malloc(MaxSize * sizeof(ElementType));
	Q->front = Q->rear = 0;
	Q->Size = Size;
	return Q;
	
}

template<class T>
Graph<T>::Graph(T a[], int n, int m)
{
    vertexnum = n;
    edgenum = m;
    for (int i = 0; i < vertexnum; i++) 
        vertex[i] = a[i];
    for (int i = 0; i < vertexnum; i++) 
        for (int j = 0; j < vertexNum; j++)
            edge[i][j] = 0;
    for (int k = 0; k < edgenum; k++)
    {
        int i, j;
        std::cin >> i >> j;        
        edge[i][j] = 1;         
        edge[j][i] = 1;
    }
    for (int i = 0; i <vertexnum; i++)
    {
        vertexnode = a[i];
        firstedge = NULL;
    }
    for (int k = 0; k < edgenum; k++)
    {
        int i, j;
        std::cin >> i >> j;
        Graph* s = new Graph;
        adjvex = j;
        s->next = firstedge;
        firstedge = s;
    }
